﻿@Html.DevExpress().GridView(
            settings =>
            {
                settings.Name = "gvEditing";
                settings.KeyFieldName = "FAllowanceFileID";
                settings.CallbackRouteValues = new { Controller = "AllowanceFileAudit", Action = "AllowanceFileAuditListPartial" };
                settings.Width =System.Web.UI.WebControls.Unit.Percentage(99);
                settings.Columns.Add("FStatusStr", "状态").Width = 50;
                settings.Columns.Add(column =>
                {
                    column.Caption = "操作";

                    column.SetDataItemTemplateContent(c =>
                    {
                        if (DataBinder.Eval(c.DataItem, "FStatus").ToString() == "1")
                        {
                            //Html.DevExpress().HyperLink(s => { s.Name = "linkEdit" + c.VisibleIndex; s.Properties.Text = "查看"; s.ToolTip = "查看"; s.Properties.ImageUrl = Url.Content("~/Content/ControlImages/button_query.png"); s.Properties.ClientSideEvents.Click = "function(){AllowanceFileLook2('" + DataBinder.Eval(c.DataItem, "FAllowanceFileID") + "')}"; s.Style.Add(HtmlTextWriterStyle.Cursor, "pointer"); }).GetHtml();

                            Html.DevExpress().HyperLink(s => { s.Name = "linkLook" + c.VisibleIndex; s.Properties.Text = "文号录入"; s.ToolTip = "文号录入"; s.Properties.ImageUrl = Url.Content("~/Content/ControlImages/button_folder.gif"); s.Properties.ClientSideEvents.Click = "function(){AllowanceFileLook('" + DataBinder.Eval(c.DataItem, "FAllowanceFileID") + "')}"; s.Style.Add(HtmlTextWriterStyle.Cursor, "pointer"); }).GetHtml();
                        ViewContext.Writer.Write("  ");
                        Html.DevExpress().HyperLink(s => { s.Name = "linkDelet" + c.VisibleIndex; s.Properties.Text = "退回"; s.ToolTip = "退回"; s.Properties.ImageUrl = Url.Content("~/Content/ControlImages/button_Delete.png"); s.Properties.ClientSideEvents.Click = "function(){TaxAuditFormDel('" + DataBinder.Eval(c.DataItem, "FAllowanceFileID") + "')}"; s.Style.Add(HtmlTextWriterStyle.Cursor, "pointer"); }).GetHtml();
                       }
                        if (DataBinder.Eval(c.DataItem, "FStatus").ToString() == "2")
                        {
                            Html.DevExpress().HyperLink(s => { s.Name = "linkLook" + c.VisibleIndex; s.Properties.Text = "文号修改"; s.ToolTip = "文号修改"; s.Properties.ImageUrl = Url.Content("~/Content/ControlImages/button_folder.gif"); s.Properties.ClientSideEvents.Click = "function(){AllowanceFileLook3('" + DataBinder.Eval(c.DataItem, "FAllowanceFileID") + "')}"; s.Style.Add(HtmlTextWriterStyle.Cursor, "pointer"); }).GetHtml();
                            ViewContext.Writer.Write("  ");
                        }
                    });
                    column.Settings.AllowDragDrop = DefaultBoolean.False;
                    column.Settings.AllowSort = DefaultBoolean.False;
                    column.Width = 70;
                });


                settings.Columns.Add("FFileName", "文件名");
                settings.Columns.Add("FYear", "年度");
                settings.Columns.Add("sumFAmount", "总金额(万元)");
                
                //settings.Columns.Add("ShowDate", "开户行");
                //settings.Columns.Add("FUpdDateStr", "账号");
             
                settings.SettingsBehavior.AllowSort = false;
                settings.SettingsBehavior.AllowDragDrop = false;
                settings.SettingsBehavior.AllowSelectByRowClick = false;
                settings.SettingsLoadingPanel.Text = "数据读取中...";
                settings.SettingsBehavior.AllowClientEventsOnLoad = false;
                settings.SettingsBehavior.AllowFocusedRow = true;


                settings.ClientSideEvents.BeginCallback = "function(s,e){OnBeginCallback(s,e)}";
                
                settings.CommandColumn.Visible = true;
                settings.CommandColumn.ShowSelectCheckbox = true;
                settings.CommandColumn.Width = System.Web.UI.WebControls.Unit.Pixel(5);

                settings.SettingsPager.Position = System.Web.UI.WebControls.PagerPosition.Bottom;
                settings.SettingsPager.FirstPageButton.Visible = true;
                settings.SettingsPager.LastPageButton.Visible = true;
                settings.SettingsPager.PageSize = EnterpriseFund.Common.GlobalConstant.CONSTRING_PAGESIZE;
                settings.SettingsPager.AlwaysShowPager = true;
                
                
                settings.CommandColumn.SetHeaderTemplateContent(c =>
                {
                    Html.DevExpress().CheckBox(settingsCheckBox =>
                    {
                        settingsCheckBox.Name = "cbSelectAll";
                        settingsCheckBox.Properties.ClientSideEvents.CheckedChanged = string.Format("function(s, e) {{ if(s.GetChecked()) {0}.SelectAllRowsOnPage(); else {0}.UnselectAllRowsOnPage(); }}", settings.Name);

                        if (c.Grid.VisibleRowCount == 0)
                        {
                            settingsCheckBox.Enabled = false;

                        }
                        else
                        {
                            settingsCheckBox.Checked = c.Grid.VisibleRowCount == c.Grid.Selection.Count;
                        }


                    }).Render();
                });
                                
                
                settings.PageIndexChanged = (sender, e) =>
                {
                    ASPxGridView grid = (ASPxGridView)sender;
                    grid.Selection.UnselectAll();
                };
                settings.DataBinding = (sender, e) =>
                {
                    ASPxGridView grid = (ASPxGridView)sender;
                    for (int i = 0; i < grid.AllColumns.Count; i++)
                    {
                        if (grid.AllColumns[i].CellStyle.HorizontalAlign == System.Web.UI.WebControls.HorizontalAlign.NotSet)
                        {
                            grid.AllColumns[i].CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                        }
                        if (grid.AllColumns[i].HeaderStyle.HorizontalAlign == System.Web.UI.WebControls.HorizontalAlign.NotSet)
                        {
                            grid.AllColumns[i].HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                        }
                    }
                };            
                
                
            }).Bind(Model).GetHtml()